<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "sc_audit".
 *
 * @property integer $a_id
 * @property integer $g_id
 * @property integer $s_id
 * @property string $type
 * @property string $name
 * @property string $data
 * @property string $code
 * @property string $t_name
 *
 * @property Goods $g
 * @property Shop $s
 */
class Scaudit extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'sc_audit';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['a_id', 'type', 'name', 'data', 'code'], 'required'],
            [['a_id', 'g_id', 's_id'], 'integer'],
            [['name', 'code'], 'number'],
            [['data'], 'safe'],
            [['type', 't_name'], 'string', 'max' => 30]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'a_id' => '审核ID',
            'g_id' => '商品ID',
            's_id' => '店铺ID',
            'type' => '种类',
            'name' => '名称',
            'data' => 'Data',
            'code' => 'Code',
            't_name' => 'T Name',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getG()
    {
        return $this->hasOne(Goods::className(), ['g_id' => 'g_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getS()
    {
        return $this->hasOne(Shop::className(), ['s_id' => 's_id']);
    }
}
